/*
 * @Descripttion: Cesium系统天气
 * @version: 1.0.0
 * @Date: 2021-03-18 09:02:03
 * @LastEditTime: 2022-01-11 19:39:55
 */
import { Cartesian3 } from 'cesium';
import { WindType } from '../CustomCesium';

/**
 * @descripttion: 风力系统
 */
class WindSystem {
  //私有属性
  private direction: WindType;
  private level: number;

  /**
   * @descripttion: 构造函数
   * @param {WindType} direction 风向
   * @param {number} level 风力
   */
  constructor(direction: WindType = WindType.NONE, level = 0) {
    this.direction = direction;
    this.level = level;
  }

  /**
   * @descripttion: 设置风向
   * @param {WindType} direction 风向
   * @return {void}
   */
  setDirection(direction: WindType) {
    this.direction = direction;
  }

  /**
   * @descripttion: 获取当前风向
   * @return {WindType}
   */
  getDirection() {
    return this.direction;
  }

  /**
   * @descripttion: 设置当前风力
   * @param {number} level 风力
   * @return {void}
   */
  setLevel(level: number) {
    this.level = level;
  }

  /**
   * @descripttion: 获取当前风力
   * @return {number}
   */
  getLevel() {
    return this.level;
  }

  /**
   * @descripttion: 根据风力、风向计算向量
   * @return {Cartesian3} 向量
   */
  getWindForceVector() {
    let vectory;
    switch (this.direction) {
      case WindType.NORTH:
        vectory = new Cartesian3(0, 0, -0.2 * this.level);
        break;
      case WindType.NORTHEAST:
        vectory = new Cartesian3(0, 0.2 * this.level, -0.2 * this.level);
        break;
      case WindType.EAST:
        vectory = new Cartesian3(0.2 * this.level, 0, 0);
        break;
      case WindType.SOUTHEAST:
        vectory = new Cartesian3(0.2 * this.level, 0, 0.2 * this.level);
        break;
      case WindType.SOUTH:
        vectory = new Cartesian3(0, 0, 0.2 * this.level);
        break;
      case WindType.SOUTHWEST:
        vectory = new Cartesian3(0, -0.2 * this.level, 0.2 * this.level);
        break;
      case WindType.WEST:
        vectory = new Cartesian3(-0.2 * this.level, 0, 0);
        break;
      case WindType.NORTHWEST:
        vectory = new Cartesian3(-0.2 * this.level, 0, -0.2 * this.level);
        break;
      default:
        vectory = new Cartesian3(0, 0, 0);
        break;
    }
    return vectory;
  }
}
export default WindSystem;
